package com.senlingspace.web.controller.headquarters;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.senlingspace.common.annotation.Log;
import com.senlingspace.common.core.controller.BaseController;
import com.senlingspace.common.core.domain.AjaxResult;
import com.senlingspace.common.enums.BusinessType;
import com.senlingspace.system.domain.SlkjOperate;
import com.senlingspace.system.service.ISlkjOperateService;
import com.senlingspace.common.utils.poi.ExcelUtil;
import com.senlingspace.common.core.page.TableDataInfo;

/**
 * 运营方Controller
 * 
 * @author wangliang
 * @date 2024-07-15
 */
@RestController
@RequestMapping("/system/operate")
public class SlkjOperateController extends BaseController
{
    @Autowired
    private ISlkjOperateService slkjOperateService;

    /**
     * 查询运营方列表
     */
    @PreAuthorize("@ss.hasPermi('system:operate:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlkjOperate slkjOperate) {
        List<SlkjOperate> list = slkjOperateService.selectSlkjOperateList(slkjOperate);
        return getDataTable(list);
    }

    /**
     * 导出运营方列表
     */
    @PreAuthorize("@ss.hasPermi('system:operate:export')")
    @Log(title = "运营方", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlkjOperate slkjOperate)
    {
        List<SlkjOperate> list = slkjOperateService.selectSlkjOperateList(slkjOperate);
        ExcelUtil<SlkjOperate> util = new ExcelUtil<SlkjOperate>(SlkjOperate.class);
        util.exportExcel(response, list, "运营方数据");
    }

    /**
     * 获取运营方详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:operate:query')")
    @GetMapping(value = "/{operateId}")
    public AjaxResult getInfo(@PathVariable("operateId") Long operateId)
    {
        return success(slkjOperateService.selectSlkjOperateByOperateId(operateId));
    }

    /**
     * 新增运营方
     */
    @PreAuthorize("@ss.hasPermi('system:operate:add')")
    @Log(title = "运营方", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlkjOperate slkjOperate)
    {
        return toAjax(slkjOperateService.insertSlkjOperate(slkjOperate));
    }

    /**
     * 修改运营方
     */
    @PreAuthorize("@ss.hasPermi('system:operate:edit')")
    @Log(title = "运营方", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlkjOperate slkjOperate)
    {
        return toAjax(slkjOperateService.updateSlkjOperate(slkjOperate));
    }

    /**
     * 删除运营方
     */
    @PreAuthorize("@ss.hasPermi('system:operate:remove')")
    @Log(title = "运营方", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operateIds}")
    public AjaxResult remove(@PathVariable Long[] operateIds)
    {
        return toAjax(slkjOperateService.deleteSlkjOperateByOperateIds(operateIds));
    }
}
